package com.example.styconsumer.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.example.styinterface.interfaces.IAppleService;
import com.example.styinterface.utils.R;
import com.example.stymodel.model.Apple;

import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/apple")
public class AppleController {
    //这里不转service直接调用repository测试了
    @Reference
    private IAppleService appleService;

    @RequestMapping("/hello")
    public String hello() {
        return "helloworld";
    }
    @PostMapping("/insert")
    public R appleInsert(@RequestBody Apple apple) {

        //todo 换成统一返回结果
        return appleService.insert(apple);

    }
    @PutMapping("/update")
    public R appleUpdate(@RequestBody Apple apple) {
        return appleService.update(apple);

    }
    @DeleteMapping("/delete/{id}")
    public R appleDelete(@PathVariable("id") int id) {
        return appleService.delete(id);

    }
    @GetMapping("/selectAll")
    public R appleSelectAll() {
        return appleService.selectAll();
    }
    @GetMapping("/selectOne/{id}")
    public R appleSelectAll(@PathVariable("id") int id) {
        return appleService.selectOne(id);
    }
}